<template>
	<view class="content">
		<view class="list-box">
			<view class="title">
				{{ type == 0 ?'外观检测详情':'尺寸检测详情'}}
			</view>
			<view class="item-box" v-if="infoDetil.batchNumber">
				<view class="title">
					抽检批次号
				</view>
				<view class="text">
					{{infoDetil.batchNumber}}
				</view>
			</view>
			<view class="item-box" v-if="infoDetil.sampleNumber">
				<view class="title">
					样品编号
				</view>
				<view class="text">
					{{infoDetil.sampleNumber}}
				</view>
			</view>
			<view class="item-box" v-if="infoDetil.inspectTime">
				<view class="title">
					检验时间
				</view>
				<view class="text">
					{{infoDetil.inspectTime}}
				</view>
			</view>
			<view class="item-box" v-if="type == 0">
				<view class="title">
					外观、表面质量
				</view>
				<view class="text">
					{{infoDetil.surfaceQuality}}
				</view>
			</view>
			<view class="item-box" v-if="type == 1">
				<view class="title">
					尺寸
				</view>
				<view class="text">
					{{infoDetil.size}}
				</view>
			</view>
			<view class="item-box" v-if="infoDetil.testPass">
				<view class="title">
					是否合格
				</view>
				<view class="text">
					{{$tools.dictDispose(yes_no,infoDetil.testPass)}}
				</view>
			</view>
			<view class="item-box" v-if="infoDetil.remark">
				<view class="title">
					备注
				</view>
				<view class="text">
					{{infoDetil.remark}}
				</view>
			</view>
			<view class="item-box" v-if="infoDetil.reportFile">
				<view class="title">
					质检报告
				</view>
				<view class="">
					<view style="color: blue;width: 300rpx;overflow: hidden;">
						<span @click="pdfBnt(infoDetil.reportFile)">点击查看报告详情</span>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import * as index from '@/api/index.js'
	export default {
		data() {
			return {
				type:'',
				invoicePhotoList:[],
				baseUrl: this.$tools.baseURL,
				id: '',
				text: '',
				infoDetil: {},
				yes_no:[]
			}
		},
		onLoad(e) {
			this.id = e.id
			this.type = e.type
			this.info()
			this.dictType() // 数据字典查询
		},
		methods: {
			dictType() {
				index.typesBatch({
					'yes_no': 'yes_no',
				}).then(res => {
					this.yes_no = res.data.yes_no
				})
			},
			dateFormat(time) {
				let date = new Date(time);
				let year = date.getFullYear();
				// 在日期格式中，月份是从0开始的，因此要加0，使用三元表达式在小于10的前面加0，以达到格式统一  如 09:11:05
				let month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
				let day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
				let hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
				let minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
				let seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
				// 拼接
				// return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
				return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
			},
			isPdf(filename) {
				return filename.toLowerCase().endsWith('.docx');
				return filename.toLowerCase().endsWith('.pdf');
			},
			getFileName(filename) {
				return filename.split('/').pop();
			},
			pdfBnt(e) {
				let that = this
				uni.setStorage({
					key: 'link',
					data: that.baseUrl + e,
					success: function() {
						uni.navigateTo({
							url: '/pages/webView/index'
						})
					}
				});
			},
			info() {
				if(this.type == 0) {
					index.factoryTestSurfaceBuyId({id:this.id}).then(res => {
						this.infoDetil = res.data
					})
				} else {
					index.factoryTestSizeBuyId({id:this.id}).then(res => {
						this.infoDetil = res.data
					})
				}
			},
			inputDialogToggle(e) {
				this.text = e
				this.$refs.inputDialog.open()
			},
		}

	}
</script>

<style lang="scss">
	.content {
		padding: 20rpx;
		padding-bottom: 150rpx;

		.list-box {
			padding: 20rpx;
			background: #ffffff;
			border-radius: 8rpx;

			.title {
				padding-top: 20rpx;
				padding-bottom: 20rpx;
				color: #333;
				font-size: 28rpx;
				font-weight: bold;
			}

			.item-box {
				padding-top: 15rpx;
				padding-bottom: 15rpx;
				padding-left: 10rpx;
				display: flex;
				align-items: center;
				border-top: 1px solid #EDEDED;

				.title {
					color: #999999;
					width: 180rpx;
				}

				.text {
					width: 420rpx;
				}
			}
		}

		.bottom-box {
			position: fixed;
			bottom: 0;
			left: 0;
			width: 750rpx;
			padding: 30rpx;
			padding-bottom: 120rpx;
			height: 120rpx;
			background: #ffffff;
			display: flex;
			justify-content: space-between;

			.bnt {
				color: #ffffff;
				width: 306rpx;
				height: 88rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				border-radius: 10rpx;
				background: #4D8987;
			}
		}
	}
</style>